const users = require('../mongodb/users')
const mongodb = require('../mongodb/index')

exports.login = function(){
    return (req,res,next)=>{
        req.query.username
        mongodb.get(users,{username:req.query.username},data=>{
            if(data.length > 0){
                if(data[0].password == req.query.password){
                    req.session.userid = data[0].userid;
                    res.send('登陆成功')
                }else{
                    res.send('登陆失败，密码错误')
                }
            }else{
                res.send('登陆失败，用户信息不存在')
            }
        })
    }
}